<!--
 * @Author: 陆康永 email@email.com
 * @Date: 2024-10-23 17:08:10
 * @LastEditors: 陆康永 email@email.com
 * @LastEditTime: 2024-10-23 17:22:06
 * @FilePath: /路径动画/查看ip.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // function getLocalIP(callback) {
        //     var peerConnection = new RTCPeerConnection({ iceServers: [] });
        //     peerConnection.createDataChannel('');
        //     peerConnection.onicecandidate = function (event) {
        //         console.log("event", event)
        //         if (event.candidate) {
        //             var ip = event.candidate.candidate.split(' ')[4];
        //             callback(ip);
        //         }
        //     };
        //     peerConnection.createOffer(function (sdp) {
        //         peerConnection.setLocalDescription(sdp);
        //     }, function (error) {
        //         console.error('Failed to create offer:', error);
        //     });
        // }
        // getLocalIP(function (ip) {
        //     console.log('Local IP Address:', ip);
        // });
        fetch('https://ipinfo.io/json?token=1353864c83dab6')
            .then(response => response.json())
            .then(data => {
                console.log('Your IP address is:', data.ip);
                document.body.innerHTML = 'Your IP address is:' + data.ip
            })
            .catch(error => {
                console.error('Error fetching IP:', error);
                document.body.innerHTML = 'Error fetching IP:' + error
            });
    </script>
</body>

</html>